package com.woniu51.auth.controller;

import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.core.domain.model.LoginBody;
import com.woniu51.auth.service.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杨光
 * @date 2022年03月29日 9:51
 */
@RestController
public class AuthController {


    @Autowired
    private AuthService authService;

    @RequestMapping("login")
    public AjaxResult doLogin(@RequestBody LoginBody loginBody){

        System.out.println("loginbody"+loginBody);

        String jwtToken = authService.doLogin(loginBody);
        return AjaxResult.success("ok",jwtToken);
    }

    @RequestMapping("web/login")
    public AjaxResult doWebLogin(@RequestBody LoginBody loginBody){

        System.out.println("loginbody"+loginBody);

        String jwtToken = authService.doWebLogin(loginBody);
        return AjaxResult.success("ok",jwtToken);
    }
}
